<template>
  <base-breadcrumb :title="titleName">
    <searchData :search-data="searchArr" @search="search" />

    <a-card :bordered="false">
      <!-- <title-name title="分包商技术答辩记录列表" /> -->

      <div class="table-operator">
        <a-button v-btnPermission="'pm_027_add_01'" type="primary" :loading="loading" @click="handelAdd()"> 新增分包商技术答辩记录 </a-button>
      </div>

      <div class="pub-table-select-count">
        <a-icon type="info-circle" theme="twoTone" />
        <span style="margin-right: 12px">
          分包商技术答辩记录总数：<span class="totalNum">{{ totalDels }} 个</span></span
        >
      </div>

      <list-table ref="table" size="default" row-key="key" :columns="columns" :request="loadData" :alert="true" show-size-changer show-quick-jumper show-pagination="auto">
        <span slot="serial" slot-scope="text, record, index">{{ index + 1 }}</span>
        <span slot="status" slot-scope="text">
          <a-badge :status="text | statusTypeFilter" :text="text | statusFilter" />
        </span>
        <span slot="biddingContent" slot-scope="text">
          <ellipsis :length="10" tooltip>{{ text }}</ellipsis>
        </span>
        <span slot="action" slot-scope="text, record">
          <template>
            <a v-btnPermission="'pm_027_loo_02'" @click="handleDels(record)">查看</a>
            <a-divider type="vertical" v-btnPermission="'pm_027_edi_03'" />
            <a v-btnPermission="'pm_027_edi_03'" @click="handleEdit(record)">编辑</a>
          </template>
        </span>
      </list-table>
    </a-card>
  </base-breadcrumb>
</template>

<script>
import { STable, Ellipsis } from '@/components'
import { getdefenceRecordsList, getdefenceRecordOne, addDefenceRecords } from '@/api/subcontractors/defenceRecord'
import { getTypes } from '@/api/commons'
import SelectSubCompany from '@/components/Select/SelectSubCompany' // 分公司
import OrgTreeSelect from '@/components/OrgTreeSelect'
import ARow from 'ant-design-vue/es/grid/Row'

const columns = [
  {
    title: '序号',
    width: 65,
    scopedSlots: { customRender: 'serial' }
  },
  {
    title: '项目名称',
    width: 100,
    dataIndex: 'projectName'
  },
  {
    title: '项目编号',
    width: 100,
    dataIndex: 'projectNum'
  },
  {
    title: '分公司',
    width: 100,
    dataIndex: 'branchCompanyName'
  },
  {
    title: '招标内容',
    width: 100,
    dataIndex: 'biddingContent',
    scopedSlots: { customRender: 'biddingContent' }
  },
  {
    title: '计划选择分包商个数',
    width: 160,
    dataIndex: 'planSubSize'
  },
  {
    title: '参与投标分包商个数',
    width: 160,
    dataIndex: 'participateBidders'
  },
  {
    title: '通过投标分包商个数',
    width: 160,
    dataIndex: 'throughBidding'
  },
  {
    title: '创建人',
    width: 90,
    dataIndex: 'creatorName'
  },
  {
    title: '创建时间',
    width: 100,
    dataIndex: 'creatorDate'
  },
  {
    title: '操作',
    dataIndex: 'action',
    width: 150,
    scopedSlots: { customRender: 'action' }
  }
]

export default {
  name: 'a' + Date.now(),
  components: {
    STable,
    Ellipsis
  },
  data() {
    this.columns = columns
    return {
      loading: false,
      searchArr: [
        {
          name: '所属单位',
          valueKey: 'searchQuery',
          type: OrgTreeSelect,
        },
        // 搜索框
        // {
        //   name: '项目名称',
        //   value: 'projectName',
        //   type: 'input'
        // },
        // {
        //   name: '分公司',
        //   valueKey: 'branchComId',
        //   type: SelectSubCompany
        // },
        // {
        //   name: '招标内容',
        //   value: 'biddingContentId',
        //   type: 'select',
        //   data:[]
        // },
        {
          // name: '创建时间',
          // value: 'startTime',
          // type: 'dateRange'
          name: '创建时间',
          value: 'createdTime',
          type: 'dateRange'
        },
        {
          name: '创建人',
          value: 'creatorId',
          type: 'input'
        }
      ],
      titleName: '',

      // 高级搜索 展开/关闭
      advanced: false,
      // 查询参数
      queryParam: {},
      // 加载数据方法 必须为 Promise 对象
      loadData: (parameter) => {
        if (this.queryParam.createdTime && this.queryParam.createdTime.length > 0) {
          this.queryParam.startTime = this.queryParam.createdTime[0].format('YYYY-MM-DD')
          this.queryParam.endTime = this.queryParam.createdTime[1].format('YYYY-MM-DD')
          delete this.queryParam.createdTime
        }
        const requestParameters = Object.assign({}, parameter, this.queryParam)
        return getdefenceRecordsList(requestParameters).then((res) => {
          this.totalDels = res.totalSize
          return res
        })
      },
      selectedRowKeys: [],
      selectedRows: [],
      totalDels: {}
    }
  },

  created() {
    // this.getTypes()
  },
  computed: {
    // rowSelection() {
    //   return {
    //     selectedRowKeys: this.selectedRowKeys,
    //     selectedRows: this.selectedRows,   // 当前行所有数据
    //     onChange: this.onSelectChange
    //   }
    // }
  },
  methods: {
    // getTypes(){
    //   getTypes({type:33}).then(res=>{
    //     this.searchArr[2].data = this.getChangeDatatTypes(res.data)
    //   })
    // },
    search(val) {
      // console.log("val",val)
      this.queryParam = val

      // if(val.startTime){
      //   this.queryParam.startTime = this.formatDate((val.startTime[0]))
      //   this.queryParam.endTime = this.formatDate((val.startTime[1]))
      // }
      this.$refs.table.refresh(true)
    },

    handelAdd() {
      this.loading = true
      addDefenceRecords().then((res) => {
        if (res.code == 200 || res.data.code == 200) {
          this.loading = false
          this.$router.push({ path: '/subcontractors/defenceRecord/add', query: { replyId: res.data.id, isEdit: 0 } })
        }
      })
    },

    handleDels(val) {
      this.$router.push({ path: '/subcontractors/defenceRecord/details', query: { replyId: val.id } })
    },

    handleEdit(val) {
      this.$router.push({ path: '/subcontractors/defenceRecord/add', query: { replyId: val.id, isEdit: 1 } })
    },

    onSelectChange(selectedRowKeys, selectedRows) {
      this.selectedRowKeys = selectedRowKeys
      this.selectedRows = selectedRows
    }
  }
}
</script>


